import Qt 4.7

Item {
    id: container

    signal clicked

    property string text

    BorderImage {
        id: btnNormal
        source: "images/toolbutton.sci"
        width: container.width; height: container.height
    }
    BorderImage {
        id: btnPressed
        opacity: 0
        source: "images/toolbutton.sci"
        // for debug
        //source: "images/toolbutton_pressed.sci"
        width: container.width; height: container.height
    }
    MouseArea {
        id: btnArea
        anchors.fill: parent
        onClicked: { container.clicked(); }
    }
    Text {
        id: btnText
        font.pointSize: fontSize
        text: container.text
        anchors.centerIn: btnNormal
        style: Text.Raised
        styleColor: "black"
        color: "#ffffff"
    }
    states: [
        State {
            name: "Pressed"
            when: btnArea.pressed == true
            PropertyChanges {
                target: btnPressed
                opacity: 1
            }
        },
        State {
            name: "Focused"
            when: container.activeFocus == true
            PropertyChanges {
                target: btnText
                color: "#ffffff"
            }
        }
    ]
    transitions: [
        Transition {
            ColorAnimation { target: btnText; }
        }
    ]
}
